<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="container">
      <div class="box">1111</div>
      <div>222</div>
    </div>
    <script>
      //增：create  删：remove removeChild修改
      var containerEle = document.querySelector(".container");
      var box = document.querySelector(".box");
      var myP = document.createElement("p");
      //   myP.innerHTML = "我是伞兵";
      //   document.onclick = function () {
      //     containerEle.replaceChild(myP, box);
      //   };
      //添加元素；父元素.insertBefore(新添加的元素，要添加的元素之前)
      //   var pEle = document.createElement("p");
      //   pEle.innerHTML = "你是伞兵";
      //   document.onclick = function () {
      // containerEle.insertBefore(pEle, box);
      //   };

      //克隆元素cloneNode:默认会克隆元素，不会克隆子元素；默认参数是false 参数如果是true那么会克隆子元素
      //   var containerEle = document.querySelector(".container")
      //   var newConatiner = containerEle.cloneNode(true)
      //   console.log(newConatiner)
    </script>
  </body>
</html>
